package cn.qu.netty.boot;

import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

import cn.qu.util.PrintUtils;

public class Log {

	static final PrintStream writer = System.out;
	static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.sss");

	private volatile static Log log;
	
	private Log() {}

	public static synchronized Log createLog() {
		if (log == null) {
			log = new Log();
		}
		return log;
	}

	public void log(String msg) {
		StackTraceElement[] stackTrace = new Exception().getStackTrace();
		PrintUtils.Color color = PrintUtils.Color.LIGHT_PURPLE;
		PrintUtils
				.println("[" + dateFormat.format(new Date()) + " - " + stackTrace[1].toString() + "]: ", color);

		PrintUtils.println(msg, PrintUtils.Color.BLACK, PrintUtils.Style.BOLD, 100);
	}

	
}
